package com.cy.bfzcommons.web.util;

import lombok.Getter;
import lombok.Setter;

/**
 * @author Administrator
 * json响应结构
 */
public class JsonResult {
    private int status;                          //状态码 (200成功 201失败)
    private String message;                     //响应信息
    private Object  data;                       //正文

    private JsonResult(int status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public JsonResult(){}

    public static JsonResult fail(){
        return new JsonResult(201,"服务器处理失败",null);
    }
    public static JsonResult fail(Object data){
        return new JsonResult(201,"服务器处理失败",data);
    }

    public static JsonResult ok(){
        return new  JsonResult(200,"服务器处理成功",null);
    }

    public static JsonResult ok(Object data){
        return new JsonResult(200,"服务器处理成功",data);
    }

    public static JsonResult ok(String message,Object data){
        return new JsonResult(200,message,data);
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}